$(function(){
	/*疫苗知识*/
	var pages;
	ym.ajax({
		url:'/article/getMenuArticle',
		param:{ menuTagId:10 },
		success:function(data){
			console.log(data);
			var html = "";
			var html2 = "";
			if(data.res ==1){
				$('.am-list').html("");
				pages = data.obj.pageNum;
				if(data.obj.results.length > 0){
					for(var i=0;i<data.obj.results.length;i++){
						var ress = data.obj.results[i];
						html += '<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left hand knowledge">'              
									html +='<div class="am-u-sm-3 am-list-thumb">'
										html +='<img src="'+ress.articleCoverUlr+'" alt="零星！"/>'
									html +='</div>'
									html +='<div class=" am-u-sm-8 am-list-main w72">'
										html +='<h3 class="am-list-item-hd whitespace">'+ress.articleTitle+'</h3>'
										if(ress.articleDescribe == null){
											html +='<div class="am-list-item-text am-margin-0"></div>'
										}else{
											html +='<div class="am-list-item-text am-margin-0">'+ress.articleDescribe+'</div>'
										}
										html +='<i class="none">'+ress.articleId+'</i>'
									html +='</div>'
								html +='</li>';
					}
					$('.am-list').append(html);
				}else{
					html = '<li class="am-text-center"><img style="height:150px" src="../img/no.jpg"></li>';
					$('.am-list').append(html);
				}
				if(data.obj.totalRecord > 5){
					$('.more').removeClass('none');
				}
			}else{console.log("数据获取失败！")}
		}
	});
	
	/*点击查看更多*/
	$('body').on('click','.more',function(){
		$("#my-modal-loading").modal('open');
		pages = pages + 1;
		ym.ajax({
			url:'/article/getMenuArticle',
			param:{ 
				menuTagId:10,
				pageNum:pages,
			},
			success:function(data){
				setTimeout(function(){
					$("#my-modal-loading").modal('close');
				},300)
				console.log(data);
				var html = "";
				if(data.res ==1){
					for(var i=0;i<data.obj.results.length;i++){
						var ress = data.obj.results[i];
						html += '<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left hand knowledge">'              
									html +='<div class="am-u-sm-3 am-list-thumb">'
										html +='<img src="'+ress.articleCoverUlr+'" alt="零星！"/>'
									html +='</div>'
									html +='<div class=" am-u-sm-8 am-list-main w72">'
										html +='<h3 class="am-list-item-hd">'+ress.articleTitle+'</h3>'
										if(ress.articleDescribe == null){
											html +='<div class="am-list-item-text am-margin-0"></div>'
										}else{
											html +='<div class="am-list-item-text am-margin-0">'+ress.articleDescribe+'</div>'
										}
										html +='<i class="none">'+ress.articleId+'</i>'
									html +='</div>'
								html +='</li>';
					}
					$('.am-list').append(html);
					if(data.obj.results.length < 5){
						$('.more').html('');
						$('.more').html('<p>到底啦</p>');
						$('.more').removeClass('more');
					}
				}else{console.log("数据获取失败！")}
			}
		});
	})
	
	$('body').on('click','.knowledge',function(){
		var id = $(this).find('i').text();
		console.log(id);
		ym.ajax({
			url:'/article/updateArticleReadNumber',
			type:"post",
			param:{ articleId:id },
			success:function(data){
				if(data.res == 1){
					console.log("跳转页面成功")
				}else{console.log("跳转页面失败")}
				window.location.href='yimiaozhishiXQ.html?articleId='+id;
			}
		});
	})
})
